import React from 'react';
import ReactDOM from 'react-dom';
import Router from './routers/Route';

window.util = require('./views/util.js');

window.onload = function () {

    let tokenCookie = util.getCookie("customer") || "";  // 获取cookie中的 customer
    let tokenString = JSON.parse(tokenCookie) || "";  //JSON字符串解析成json对象,但结果带""号
    let tokenObject = eval("("+tokenString+")") || {};  //去除JSON外层的""号

    window.app = {
        info: {
            openID: tokenObject.id,  //用户customerId
            wechatOpenId: tokenObject.wechatOpenId,   //微信openId
            mallID: tokenObject.mallId,  //平台id
            domain: tokenObject.mallCustomerDomain,
            userToken: tokenObject.userToken,
            isBindingMobile: tokenObject.isBindingMobile,
        }
    };



    ReactDOM.render(
        Router,
        document.querySelector('#app')
    );
};
